﻿using System.IO;
using System.Net.Mime;
using System.Text;
using Karma.Framework.Core.Services.Infrastructure;
using NUnit.Framework;

namespace Karma.Framework.Core.Test.Services
{
    [TestFixture]
    public class EmailServiceFixture
    {
        [Test]
        public void SendEmailTest()
        {
            var service = new EmailService();

            var result = service.SendEmail("cguzman@globalab.com.mx", 
                new []{ "trentcioran@gmail.com" }, 
                "Test email", 
                "This is a test email with karma email service.", 
                Encoding.UTF8, false);


            Assert.IsTrue(result);
        }

        [Test]
        public void SendEmailWithAttatchmentTest()
        {
            var service = new EmailService();

            var result = service.SendEmail("cguzman@globalab.com.mx",
                new[] { "trentcioran@gmail.com" },
                "Test email",
                "This is a test email with karma email service. I have sent App.config as an attatchment.",
                Encoding.UTF8, false,

                new[] { "..\\..\\App.config" },
                new[] { MediaTypeNames.Text.Xml });

            Assert.IsTrue(result);
        }

        [Test]
        public void SendEmailWithStreamAttatchmentTest()
        {
            var service = new EmailService();

            var result = service.SendEmail("cguzman@globalab.com.mx",
                new[] { "trentcioran@gmail.com" },
                "Test email",
                "This is a test email with karma email service. I have sent App.config as an stream attatchment.",
                Encoding.UTF8, false,
                new[] { new FileStream("..\\..\\App.config", FileMode.Open, 
                    FileAccess.Read, FileShare.ReadWrite) },
                new[] { MediaTypeNames.Text.Xml });

            Assert.IsTrue(result);
        }
    }
}
